package com.sky.mapper;

import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressBookMapper {
	
	/**
	 * 新增地址
	 *
	 * @param addressBook
	 */
	void addAddress(AddressBook addressBook);
	
	/**
	 * 查询地址
	 *
	 * @param addressBook
	 * @return
	 */
	List<AddressBook> getAddress(AddressBook addressBook);
	
	/**
	 * 查询默认地址
	 *
	 * @param addressBook
	 * @return
	 */
	@Select("select * from address_book where user_id = #{userId} and is_default=#{isDefault}")
	AddressBook getDefault(AddressBook addressBook);
	
	/**
	 * 修改地址
	 *
	 * @param addressBook
	 */
	void putAddress(AddressBook addressBook);
	
	/**
	 * 删除地址
	 *
	 * @param id
	 */
	@Delete("delete from address_book where id = #{id}")
	void deleteAddress(Long id);
}
